<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>签到</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    html, body {
      height: 100%;
      overflow: hidden;
    }
    body {
      background: url('./i/bg1.png');
      background-position: 0 -1vh;
      background-size: cover;
    }
    .topbar {
      color: white;
      background-color: #FF4F4F;
      padding: 0 10px;
    }
    .topbar * {
      color: white;
      text-decoration: none;
    }
    .topbar td {
      height: 7vh;
    }
    .content {
      text-align: center;
      margin-top: 3vh;
    }
    .content > div:first-child {
      font-weight: bold;
      font-size: 1.2rem;
    }
    .content > div:first-child span {
      color: #FF4F4F;
      font-size: 1.4em;
    }
    .content > div:last-child {
      margin-top: 3px;
      font-size: 0.9rem;
    }
    .btn {
      margin-top: 1vh;
      padding: 0 12vw;
    }
    .btn img {
      height: 7vh;
    }
    .grid {
      position: absolute;
      bottom: 1vh;
      text-align: center;
    }
    .grid table {
      width: 100%;
      padding: 0 5vw;
      table-layout: fixed;
    }
    .grid td {
      text-align: center;
    }
    .grid img {
      width: 80%;
    }
    .grid td {
      position: relative;
    }
    .grid td span {
      position: absolute;
      left: 50%;
      top: 45%;
      color: red;
      font-weight: bold;
      transform: translate(-50%, -50%);
    }
    .grid td.active span {
      color: white;
    }
    .grid tr:nth-child(even) {
      font-size: 0.7rem;
      color: white;
    }
    .grid tr:nth-child(odd) td:nth-child(1)::after,
    .grid tr:nth-child(odd) td:nth-child(2)::after,
    .grid tr:nth-child(odd) td:nth-child(3)::after,
    .grid tr:nth-child(odd) td:nth-child(4)::after,
    .grid tr:nth-child(odd) td:nth-child(5)::after {
      content: "";
      display: block;
      position: absolute;
      top: 45%;
      left: 90%;
      width: 20%;
      height: 4px;
      margin-top: -2px;
      background: url('i/图片8.png');
      background-size: cover;
    }
    .grid tr:nth-child(1) td:nth-child(6)::before,
    .grid tr:nth-child(3) td:nth-child(1)::before,
    .grid tr:nth-child(5) td:nth-child(6)::before,
    .grid tr:nth-child(7) td:nth-child(1)::before {
      content: "";
      display: block;
      position: absolute;
      top: 90%;
      left: 50%;
      width: 4px;
      height: 60%;
      margin-left: -2px;
      background: url('i/图片9.png');
      background-size: cover;
    }

    #msg {
      position: relative;
      display: none;
      background: url('i/图片14.png');
      background-size: 100% 100%;
      position: fixed;
      width: 75vw;
      height: 79.1vw;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: white;
      padding: 6vw;
      box-sizing: border-box;
    }
    #msg .title {
      text-align: center;
      font-weight: bold;
      font-size: 1.5rem;
      margin-bottom: 8vw;
    }
    #msg .title ~ div {
      padding: 0px 2vw;
    }
    #msg img {
      height: 7vh;
      position: absolute;
      left: 7vw;
      bottom: 8vw;
    }
    #msg img ~ img {
      left: unset;
      right: 7vw;
    }

    #msgrule {
      position: relative;
      display: none;
      background: url('i/图片11.png');
      background-size: 100% 100%;
      position: fixed;
      width: 85vw;
      height: 102.3vw;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: white;
      padding: 5vw;
      box-sizing: border-box;
    }
    #msgrule .title {
      text-align: center;
      font-weight: bold;
      font-size: 1.5rem;
      margin-bottom: 2vw;
    }
    #msgrule .title ~ div {
      font-size: 0.9rem;
    }
    #msgrule img {
      height: 7vh;
      position: absolute;
      left: 50%;
      bottom: 6vw;
      transform: translate(-50%, 0);
    }
  </style>
</head>
<body>
  <div class="topbar">
    <table width="100%">
      <tr>
        <td width="33.33%"><a id="back" href="#">&lt;返回</a></td>
        <td width="33.34%" style="font-size:1.1rem;text-align:center;">签到</td>
        <td width="33.33%" style="text-align:right"><a id="rule" href="#">活动规则</a></td>
      </tr>
    </table>
  </div>
  <div class="content">
    <div>已累计签到 <span id="days">3</span> 天</div>
    <div>还有<span id="rest">7</span>天获得<span id="nextexp">50</span>点经验值</div>
  </div>
  <div class="btn">
    <table width="100%">
      <tr>
        <td width="50%"><img id="shop" src="./i/btn1.png" /></td>
        <td width="50%" style="text-align:right"><img id="record" src="./i/btn2.png" /></td>
      </tr>
    </table>
  </div>
  <div class="grid">
    <table>
      <tr>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /><span>10</span></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td>第3天</td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /><span>50</span></td>
        <td width="1"><img src="i/图片6.png" /></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td>第8天</td>
        <td></td>
      </tr>
      <tr>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /><span>90</span></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td>第15天</td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /><span>110</span></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
      </tr>
      <tr>
        <td></td>
        <td>第23天</td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /></td>
        <td width="1"><img src="i/图片6.png" /><span>140</span></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td>第30天</td>
      </tr>
    </table>
    <img id="signin" style="width:auto;height:8vh;" src="i/图片10.png" />
  </div>
  <div id="msg">
    <div class="title">签到成功！</div>
    <div>您已累计签到第【<span id="msg_cur"></span>】天，获得经验值：<span id="msg_exp"></span>，总计：<span id="msg_total"></span>，100积分可抽奖，400积分即可兑换，继续努力哟~</div>
    <img id="close1" src="i/图片15.png" />
    <img id="share" src="i/图片16.png" />
  </div>
  <div id="msgrule">
    <div class="title">活动规则</div>
    <div>
      累计签到3、8、15、23、30天，分别获得奖励10点、50点、90点、110点、140点经验值；<br>
      累计100点经验值可抽奖一次，10点经验值=1M流量；<br>
      签到中断，累计签到天数中断，签到周期内下次签到继续累计。已获经验值保留在账户中，有效期三个月；<br>
      仅限联通手机号绑定微信的用户参与；<br>
      抽奖抽中积分则立即发送到用户账户；<br>
      流量兑换充值到账后立即生效，当月有效；<br>
      本活动最终解释权归微信WO玩转流量公众号所有。
    </div>
    <img id="close2" src="i/图片12.png" />
  </div>
  <script>
    var current = 0;
    var exp = 0;

    function $(selector) {
      return document.querySelector(selector);
    }

    $('#signin').onclick = function(e) {
      var elem = e.target;
      elem.style.visibility = 'hidden';
      current++;
      showMsg();
      renderDay(current);
    };

    $('#close1').onclick = function() {
      $('#msg').style.display = 'none';
    };
    $('#share').onclick = function() {
      $('#msg').style.display = 'none';
      //
    };

    $('#back').onclick = function() {
      //
    };
    $('#rule').onclick = function() {
      $('#msgrule').style.display = 'block';
    };
    $('#close2').onclick = function() {
      $('#msgrule').style.display = 'none';
    };

    $("#shop").onclick = function() {
      location.href = "shop.html";
    };
    $("#record").onclick = function() {
      //
    };

    function showMsg() {
      $('#msg').style.display = 'block';
      $('#msg_cur').innerHTML = current;
      var nextinfo = getNext(current - 1);
      if (nextinfo[0] == 1) {
        $('#msg_exp').innerHTML = nextinfo[1];
        exp += nextinfo[1];
      } else {
        $('#msg_exp').innerHTML = 0;
      }
      $('#msg_total').innerHTML = exp;
    }

    function renderDay(days) {
      for (var i = 1; i <= days; i++) {
        var elem = getTd(i);
        if (!elem) return;
        if (i == 3 || i == 8 || i ==15 || i ==23 || i == 30) {
          elem.innerHTML = elem.innerHTML.replace('图片6', '图片5');
          elem.className = 'active';
        }
        else
          elem.innerHTML = elem.innerHTML.replace('图片6', '图片4');
      }

      $('#days').innerHTML = days;
      var nextinfo = getNext(days);
      $('#rest').innerHTML = nextinfo[0];
      $('#nextexp').innerHTML = nextinfo[1];
    }
    function getTd(day) {
      if (day < 1 || day > 30) return;
      day--;
      var row = Math.floor(day / 6);
      var col = row % 2 == 0 ? day % 6 : 5 - day % 6;
      return $('.grid tr:nth-child('+(row*2+1)+') td:nth-child('+(col+1)+')');
    }
    function getNext(day) {
      if (day < 3) {
        return [3 - day, 10];
      } else if (day < 8) {
        return [8 - day, 50];
      } else if (day < 15) {
        return [15 - day, 90];
      } else if (day < 23) {
        return [23 - day, 110];
      } else {
        return [30 - day, 140]; 
      }
    }

    renderDay(current);
  </script>
</body>
</html>